<?php

namespace plugin\laoha\app\controller;

use plugin\laoha\app\model\Comment;
use plugin\laoha\app\validate\CommentValidate;
use support\Request;

class CommentController extends Crud
{
  protected $noNeedLogin = ['index', 'list', 'select', 'show'];
  protected $dataLimit = "personal"; 
  protected $dataLimitField = "user_id"; 

  public function __construct()
  {
    $this->model = new Comment;
    $this->validate = new CommentValidate;
  }


  public function index(Request $request)
  {
    $root_id=$request->input('root_id',0);
    $root=$request->input('root','');
    return view('comment/index',['params'=>['root_id'=>$root_id,'root'=>$root,'admin_id'=>admin_id(),'rules'=>$this->getRules()]]);
  }

  public function list(Request $request)
  {		
    $this->set=['parent_id'=>0,'no_where'=>'id'];
		$this->model = $this->model->with(['user:id,nickname,avatar','comments']);
		return parent::list($request);
  }
}
